local path "C:\Users\pgi1\Dropbox\Coal 2021 _ Joe Peter\Bank Regressions\"
cd "`path'\data"
set seed 100
set more off
clear




use  loan_year_vars_dataset, clear


//edit if lender=="BofA Securities"

bysort ultimateparentid year: keep if _n==1
xtset ultimateparentid year

keep if year>=2000 & year<=2020



est clear




xtreg loans_mtr_ln treated treated_has_article has_article log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e1
estadd local fes "Bank and Year"


xtreg loans_mtr_ln treated treated_has_deposits has_deposits log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e2
estadd local fes "Bank and Year"


xtreg loans_mtr_ln treated treated_large large_bank log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e3
estadd local fes "Bank and Year"



esttab e1 e2 e3  using "`path'\tables\table-4.rtf",  replace compress nogaps se onecell b(3) modelwidth(6) ///
title("Table 4. Panel A. Number of Loans to MTR-affiliated borrowers") nomtitles ///
stats(fes r2_a  N , fmt(%9.0fc %9.3fc %9.0fc ) labels("Fixed Effects" "Adj. R-squared" "Observations" ) ) ///
label collabels(none)  starlevels(* 0.10 ** 0.05 *** 0.01) nonote ///
order(treated_has_article treated_has_deposits treated_large  treated  log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  has_article has_deposits large_bank) keep(treated_has_article treated_has_deposits treated_large  treated  log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  has_article has_deposits large_bank)




est clear




xtreg loans_mtr_total treated treated_has_article has_article log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e1
estadd local fes "Bank and Year"


xtreg loans_mtr_total treated treated_has_deposits has_deposits log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e2
estadd local fes "Bank and Year"


xtreg loans_mtr_total treated treated_large large_bank log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  y_*, fe vce(cluster ultimateparentid)
est store e3
estadd local fes "Bank and Year"



esttab e1 e2 e3  using "`path'\tables\table-4.rtf",  append compress nogaps se onecell b(3) modelwidth(6) ///
title("Panel B. Ratio of Loans Amounts to MTR-affiliated borrowers to Total Loan Amounts") nomtitles ///
stats(fes r2_a  N , fmt(%9.0fc %9.3fc %9.0fc ) labels("Fixed Effects" "Adj. R-squared" "Observations" ) ) ///
label collabels(none)  starlevels(* 0.10 ** 0.05 *** 0.01) nonote ///
order(treated_has_article treated_has_deposits treated_large  treated  log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  has_article has_deposits large_bank) keep(treated_has_article treated_has_deposits treated_large  treated  log_assets asset_growth_3 loans_total_lag3_ln  loans_related_lag3_ln  has_article has_deposits large_bank)


exit
